import myAxios from "@/request";

export interface AbbreviationSpaceVo {
    id?: Number
    spaceName?: string;
    spaceLevel?: number;
    totalCount?: Number;
    memberAvatars?: [];
}

export const getAbbreviationSpaceVoRequestByGet = () => {
    return myAxios.request({
        method: "GET",
        url: "/space/abbreviation"
    })
}

export interface CreateSpaceRequest {
    /**
     * 空间名称
     */
    spaceName?: string;

    /**
     * 空间简介
     */
    profile?: string;

    /**
     * 空间级别：0-普通版 1-专业版 2-旗舰版
     */
    spaceLevel?: number;

}

export const createSpaceRequestByPost = (createSpaceRequest: CreateSpaceRequest) => {
    return myAxios.request({
        method: "POST",
        url: "/space/create",
        data: createSpaceRequest
    })
}

export interface SpaceVo {
    /**
     * id
     */
    id?: Number;

    /**
     * 空间名称
     */
    spaceName?: string;

    /**
     * 空间级别：0-普通版 1-专业版 2-旗舰版
     */
    spaceLevel?: number;

    /**
     * 空间图片的最大总大小
     */
    maxSize?: Number;

    /**
     * 空间图片的最大数量
     */
    maxCount?: Number;

    /**
     * 当前空间下图片的总大小
     */
    totalSize?: Number;

    /**
     * 当前空间下的图片数量
     */
    totalCount?: Number;

    /**
     * 创建时间
     */
    createTime?: Date;

    /**
     * 更新时间
     */
    updateTime?: Date;

    profile?: string;

    spaceUserAvatars?: string[];
}

export const getSpaceDetailRequestByGet = (id: Number | null) => {
    return myAxios.request({
        method: "GET",
        url: `/space/search/vo/${id}`,
    })
}

export interface SpaceUserVo {
    userId?: Number;
    avatar?:string
    nickname?: string
    spaceUserRole?:string;
    permissions?: string[];
}


export const getSpaceUserAuthByGet = (spaceId: Number | null) => {
    return myAxios.request({
        method:"GET",
        url: `/space/user/${spaceId}`,
    })
}

export const getSpaceUserListByGet = (spaceId: Number | null) => {
    return myAxios.request({
        method:"GET",
        url: `/space/users/${spaceId}`,
    })
}

export interface SpaceInviteUserRequest {
    userId?: Number;
    // 空间id
    id?: Number;
    username?: string;
    spaceUserRole?: string;
}

export const spaceInviteUserRequestByPost = (spaceInviteUserRequest:SpaceInviteUserRequest) => {
    return myAxios.request({
        method:"POST",
        url: `/space/invite`,
        data: spaceInviteUserRequest
    })
}